home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8180 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  50 lines

  1. Path: news.crystalball.com!news
  2. From: Larry Weiss <lfw@oc.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie doesn't understand compiler error
  5. Date: Fri, 01 Mar 1996 17:56:59 -0600
  6. Organization: crystalball.com
  7. Message-ID: <31378ECB.3B81@oc.com>
  8. References: <Pine.SUN.3.91.960301153010.11258B-100000@pioneer.uspto.gov>
  9. NNTP-Posting-Host: external.oc.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14.  
  15. Max Schubert wrote:
  16.  > 
  17.  > I have just started to work with two different learning C books.  They
  18.  > both have programs to copy and compile as I go along.  Twice I have
  19.  > received this error from cc when attempting to compile two separate
  20.  > programs on SunOS 4.1.2:
  21.  > 
  22.  > #include <stdio.h>
  23.  > void do_heading(char *filename);
  24.  > int line, page;
  25.  > main( int argv, char *argc[] )  <<- Compiler states "Syntax error at or near
  26.  > {                                   word type char."
  27.  > 
  28.  > Do I need to update my compiler?
  29.  > 
  30.  >         ANY help would be greatly appreciated.
  31.  
  32. First off, you may have made a typo here, but the correct declaration of main() is
  33.  
  34.   main( int argc, char *argv[] ) 
  35.                ^           ^ 
  36.  
  37. The compiler that Sun provides with SUNOS 4.1 does not support function
  38. declarations of the type you are using.   This method was introduced into
  39. the language at the most recent major standardization cycle. 
  40. You will need to either use a different compiler, or translate any function
  41. prototypes into the older form of argument declaration.   For example, code the 
  42. declaraction of main() as:
  43.  
  44.  main( argc, argv ) 
  45.  int argc;
  46.  char *argv[];
  47.  { 
  48.    ...
  49.  }
  50.